package com.elong.spring.lifecycle;

import java.beans.PropertyDescriptor;

import org.springframework.beans.PropertyValues;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.beans.factory.config.InstantiationAwareBeanPostProcessorAdapter;

public class MyInstantiationAwareBeanPostProcessor extends
 InstantiationAwareBeanPostProcessorAdapter{
    
    //接口方法，在实例化bean前调用
    public Object postProcessBeforeInstantiation(Class beanClass, String beanName){
	//对容器中的carlifecycle bean进行处理
	if("carlifecycle".equals(beanName)){
	    System.out.println("InstantiationAwareBeanPostProcessor.postProcessBeforeInstantiation");
	}
	return null;
    }
    
    //在实例化bean后调用
    public boolean postProcessAfterInstantiation(Object bean, String beanName){
	if("carlifecycle".equals(beanName)){
	    System.out.println("InstantiationAwareBeanPostProcessor.postProcessAfterInstantiation()");
	}
	return true;
    }
    
    public PropertyValues postProcessPropertyValues(PropertyValues pvs, PropertyDescriptor[] pds,
	    Object bean, String beanName){
	if("carlifecycle".equals(beanName)){
	    System.out.println("InstantiationAwareBeanPostProcessor.postProcessPropertyValues()");
	}
	return pvs;
    }
}
